<%= render 'fae/shared/index_header', title: @klass_humanized.pluralize, csv: true %>

<main class="content">

  <%= fae_filter_form do %>
    <%= fae_filter_select :wine %>
    <%= fae_filter_select :acclaims,
          label: 'Acclaim',
          collection: Acclaim.for_release_filter,
          label_method: :score,
          placeholder: 'Select some stuff' %>
    <%= fae_filter_select :test, options: [['one', 1], ['two', 2]] %>
    <%= fae_filter_select :grouped_test, grouped_options: { 'Numbers' => [['one', 1], ['two', 2]], 'Letters' => [['The letter J', 'J'], ['The letter N', 'N']] } %>
    <%= fae_filter_select :grouped_association, collection: Aroma.all, grouped_by: :release %>
  <% end %>

  <table>
    <thead>
      <tr>
        <th>Name</th>
        <th>Wine</th>
        <th>Modified</th>
        <th>Slug</th>
        <th>Price</th>
        <th class="-action-wide">On Stage</th>
        <th class="-action-wide">On Prod</th>
        <th class="-action-wide" data-sorter="false">Edit</th>
        <th class="-action-wide" data-sorter="false">Clone</th>
        <th class="-action-wide" data-sorter="false">Delete</th>
      </tr>
    </thead>

    <tbody>
      <% if @items.present? %>
        <% @items.each do |item| %>
          <tr id="<%= "#{@klass_singular}_#{item.id}" %>">
            <td><%= link_to item.fae_display_field, edit_admin_release_path(item) %></td>
            <td><%= item.wine.name_en %></td>
            <td><%= fae_date_format item.updated_at %></td>
            <td><%= item.slug %></td>
            <td><%= item.price %></td>
            <td><%= fae_toggle item, :on_stage %></td>
            <td><%= fae_toggle item, :on_prod %></td>
            <td>
              <%= link_to edit_admin_release_path(item) do %>
                <span class="icon-edit"></span>
              <% end %>
            </td>
            <td><%= fae_clone_button item %></td>
            <td><%= fae_delete_button item %></td>
          </tr>
        <% end %>
      <% else %>
        <tr>
          <td colspan="9">No items found</td>
        </tr>
      <% end %>
    </tbody>
  </table>

</main>
